

import { ContractTransaction } from '@ethersproject/contracts';
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers';
import {ethers} from 'hardhat';
import { MonkeyKing,ArrtibuteAssertFactory } from '../src/types';

async function createAssert(addr :string ) {
    let monkeyKing = (await ethers.getContractAt("MonkeyKing",addr)) as MonkeyKing;

    let arrs  = await monkeyKing.getArrtibutesFactory();


    let txs =new  Array<ContractTransaction>(0);

    for (let i=0 ;i<arrs.length;i++){
        let factory = await ethers.getContractAt("ArrtibuteAssertFactory",arrs[i])as ArrtibuteAssertFactory
        let tx =  await factory.NewArrtibuteAssert(
            "higher",
            "0x0000000000000000000000000000000000000000",
            "0x0000000000000000000000000000000000000000",
            10,
            "悟",
            "wu"
        );

        txs.push(tx);
    }


    txs.forEach((t)=>{
        t.wait(5).then((receipt) =>{
            console.log("创建工厂成功!!")
            console.log("gas:"+receipt.gasUsed);
            console.log("区块高度:"+receipt.blockNumber);
        });
    })

}

createAssert(process.env.MONKEYKING as string);